using System;
using System.IO;
using System.Windows.Forms;

namespace FileTracker.Forms
{
    public partial class FormMakeDir : Form
    {
        private string _DestinationPath;

        public FormMakeDir(string DestinationPath)
        {
            InitializeComponent();
            _DestinationPath = DestinationPath;
            pathLabel.Text = DestinationPath;
            newPathTextBox.Focus();
        }

        private void OKButton_Click(object sender, EventArgs argEventArgs)
        {
            //Catch exceptions and report back to user
            DirectoryInfo CurrentDirectory = new DirectoryInfo(_DestinationPath);
            if (Directory.Exists(CurrentDirectory.FullName + "\\" + newPathTextBox.Text))
            {
                MessageBox.Show("Directory already exists.", "Creating directory");
                return;
            }
            try
            {
                CurrentDirectory.CreateSubdirectory(newPathTextBox.Text);
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error creating Directory.", "Creating directory");
            }
            finally
            {
                
            }
        }
    }
}